<?php
class Place extends AppModel {
	var $name = 'Place';
	var $displayField = 'name';
  var $fields = array(
    'name' => array(
      'rule' => 'required',
      'type' => 'text'
    ),
    'city' => array(
      'rule' => 'vCity',
      'type' => 'select',
      'provider' => 'cityProvider'
    ),
    'description_short' => array(
      'rule' => 'required',
      'type' => 'textarea'
    ),
    'description' => array(
      'rule' => 'required',
      'type' => 'tinymce'
    ),
    'logo_filename' => array(
      'rule' => 'required',
      'type' => 'file',
    ),
    'imagename' => array(
      'type' => 'multifile',
      'name' => 'data[Place][PlaceImage][imagename][]'
    ),
    'youtube_id' => array(
      'type' => 'multitext',
      'name' => 'data[Place][PlaceVideo][youtube_id][]'
    ),
    'phone' => array(
      'rule' => 'required',
      'type' => 'text',
    ),
    'fax' => array(
      'type' => 'text',
    ),
    'website' => array(
      'type' => 'text',
    ),
    'email' => array(
      'type' => 'text',
    ),
    'address' => array(
      'type' => 'textarea',
    ),
    'lat' => array(
      'type' => 'hidden',
      'div' => false
    ),
    'lng' => array(
      'type' => 'hidden',
      'div' => false
    ),
    'map_container' => array(
      'type' => 'map',
      'size' => 'small',
    )
  );
  /*
	var $validate = array(
		'name' => array(
			'notempty' => array(
				'rule' => 'notEmpty',
				'message' => 'Wajib diisi',
				'allowEmpty' => false,
				'required' => true,
        'last' => true,
			),
			'maxlength' => array(
				'rule' => array('maxlength', 100),
				'message' => 'Maksimal 100 karakter',
				'allowEmpty' => false,
				'required' => true
			),
		),
    'city' => array(
      'rule' => 'vCity',
      'message' => 'Pilih kota',
      'allowEmpty' => false,
      'required' => true
    ),
		'description' => array(
			'notempty' => array(
				'rule' => 'notEmpty',
				'message' => 'Wajib diisi',
				'allowEmpty' => false,
				'required' => true
			),
		),
	);*/

	var $hasMany = array(
    'PlaceImage' => array(
      'dependent' => true,
    ),
    'PlaceVideo' => array(
      'dependent' => true,
    ),
	);

  public function cityProvider() {
    return Configure::read('infojabotabek.cities');
  }
}
